package achi.community.irla.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class Achievements implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String title_sv;
    private String title_en;
    private String desc_sv;
    private String desc_en;

    private String category;
    private String sub_category;

    private String image;
    private int points;
    private String date_created;

    @OneToMany(mappedBy = "achievement", cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
    private List<Achievements_comments> achievements_comments;

     @OneToMany(mappedBy = "achievement", cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
    private List<Achievements_completed> achievements_completed;

    @OneToMany(mappedBy = "achievement", cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
    private List<Achievements_suggested> achievements_suggested;

     @OneToMany(mappedBy = "achievement", cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
    private List<Achievements_target> achievements_target;

    /**
     * only used to implement Serializable.
     */
    public Achievements() {}


    /**
     * creates a new Messages entity
     * @param fname value of the firstName column
     * @param lname value of the lastName column
     * @param email value of the email column
     * @param address value of the address column
     */
    public Achievements(String title_sv, String title_en, String desc_sv, String desc_en, String category, String sub_category, String image, int points) {
        this.title_sv = title_sv;
        this.title_en = title_en;
        this.desc_sv = desc_sv;
        this.desc_en = desc_en;
        this.category = category;
        this.sub_category = sub_category;
        this.image = image;
        this.points = points;
        date_created = (new Date()).toString();
    }

    public void setAchievements_target(List<Achievements_target> achievements_target) {
        this.achievements_target = achievements_target;
    }

    public void setAchievements_suggested(List<Achievements_suggested> achievements_suggested) {
        this.achievements_suggested = achievements_suggested;
    }

    public void setAchievements_completed(List<Achievements_completed> achievements_completed) {
        this.achievements_completed = achievements_completed;
    }

    public void setAchievements_comments(List<Achievements_comments> achievements_comments) {
        this.achievements_comments = achievements_comments;
    }

    public List<Achievements_target> getAchievements_target() {
        return achievements_target;
    }

    public List<Achievements_suggested> getAchievements_suggested() {
        return achievements_suggested;
    }

    public List<Achievements_completed> getAchievements_completed() {
        return achievements_completed;
    }

    public List<Achievements_comments> getAchievements_comments() {
        return achievements_comments;
    }

    public void setTitle_sv(String title_sv) {
        this.title_sv = title_sv;
    }

    public void setTitle_en(String title_en) {
        this.title_en = title_en;
    }

    public void setSub_category(String sub_category) {
        this.sub_category = sub_category;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public void setDesc_sv(String desc_sv) {
        this.desc_sv = desc_sv;
    }

    public void setDesc_en(String desc_en) {
        this.desc_en = desc_en;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getTitle_sv() {
        return title_sv;
    }

    public String getTitle_en() {
        return title_en;
    }

    public String getSub_category() {
        return sub_category;
    }

    public int getPoints() {
        return points;
    }

    public String getImage() {
        return image;
    }

    public String getDesc_sv() {
        return desc_sv;
    }

    public String getDesc_en() {
        return desc_en;
    }

    public String getCategory() {
        return category;
    }

    public String getDate_created() {
        return date_created;
    }

    public void setDate_created(String date_created) {
        this.date_created = date_created;
    }

    public void setDate(String date) {
        this.date_created = date;
    }


    public String getDate() {
        return date_created;
    }


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

/**
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Customer)) {
            return false;
        }
        Customer other = (Customer) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }
* */
    @Override
    public String toString() {
        return "achi.community.irla.Achievements[id=" + id + "]";
    }
}
